Skip to content

refactor: move category types and validation logic to shared package#2888

Merged
dqnykamp merged 5 commits intoDoenet:mainfrom
cqnykamp:refactor/browsable-validation
Apr 30, 2026
Merged

refactor: move category types and validation logic to shared package#2888
dqnykamp merged 5 commits intoDoenet:mainfrom
cqnykamp:refactor/browsable-validation

Conversation

@cqnykamp
Copy link
Copy Markdown
Contributor

@cqnykamp cqnykamp commented Apr 29, 2026

Summary

Move category-related types and logic to the shared package to reduce duplication and enable reuse across the platform.

Changes

  • Types moved to packages/shared/src/types/categories.ts

    • CategoryGroup - represents a group of related categories with constraints
    • Category - represents an individual category
  • Logic moved to packages/shared/src/logic/browsable.ts

    • isBrowsable() is the public interface for discoverability checks
  • Imports updated across app and api workspaces to use @doenet-tools/shared

Notes

cqnykamp and others added 5 commits April 22, 2026 11:15
- Move CategoryGroup and Category types to packages/shared/src/types/categories.ts
- Move isActivityFullyCategorized() logic to packages/shared/src/logic/browsable.ts
- Update all imports across app and api workspaces to use the shared package
- Export new types and logic from packages/shared/src/index.ts

This allows category-related code to be reused across the platform without duplication.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Keep isBrowsable as the public interface, clarify its current behavior, and export the precise category helper for reuse.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Refactors category-related types and “browsable/discoverable” validation into @doenet-tools/shared so both the app and API can reuse the same definitions and logic, reducing duplicated type declarations and helper code.

Changes:

  • Added shared Category / CategoryGroup types under packages/shared.
  • Added shared isBrowsable() logic for category-completeness checks.
  • Updated app and API imports to consume the shared types/logic and removed duplicated local type definitions.

Reviewed changes

Copilot reviewed 18 out of 18 changed files in this pull request and generated no comments.

Show a summary per file
File Description
packages/shared/src/types/categories.ts Introduces shared Category and CategoryGroup type definitions.
packages/shared/src/logic/browsable.ts Adds shared isBrowsable() logic (currently backed by category completeness).
packages/shared/src/index.ts Re-exports the new shared types and browsable logic from the package entrypoint.
apps/app/src/widgets/editor/EditCategories.tsx Switches category type imports to @doenet-tools/shared.
apps/app/src/widgets/editor/EditCategories.cy.tsx Switches CategoryGroup import to @doenet-tools/shared for tests.
apps/app/src/widgets/FilterPanel.tsx Switches CategoryGroup import to @doenet-tools/shared.
apps/app/src/widgets/FilterPanel.cy.tsx Switches CategoryGroup import to @doenet-tools/shared for tests.
apps/app/src/utils/classification.tsx Removes the locally-defined isActivityFullyCategorized() implementation (now in shared).
apps/app/src/types.ts Removes duplicated category type definitions from app-local types.
apps/app/src/popups/ShareMyContentModal.tsx Uses shared isBrowsable() instead of the removed local categorization helper.
apps/app/src/paths/editor/EditorSettingsMode.tsx Switches category type imports to @doenet-tools/shared.
apps/app/src/paths/editor/EditorSettingsMode.cy.tsx Switches category type imports to @doenet-tools/shared for tests.
apps/app/src/paths/editor/EditorHeader.tsx Uses shared isBrowsable() and switches category types to @doenet-tools/shared.
apps/app/src/paths/Explore.tsx Switches CategoryGroup import to @doenet-tools/shared.
apps/app/src/drawers/ExploreFilterDrawer.tsx Switches CategoryGroup import to @doenet-tools/shared.
apps/app/src/drawers/ExploreFilterDrawer.cy.tsx Switches CategoryGroup import to @doenet-tools/shared for tests.
apps/api/src/types.ts Removes duplicated category type definitions from API-local types.
apps/api/src/query/classification.ts Switches CategoryGroup type usage to come from @doenet-tools/shared.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@cqnykamp cqnykamp marked this pull request as ready for review April 29, 2026 17:52
@cqnykamp cqnykamp requested a review from dqnykamp April 29, 2026 17:52
@dqnykamp dqnykamp merged commit dc41519 into Doenet:main Apr 30, 2026
28 checks passed
@cqnykamp cqnykamp deleted the refactor/browsable-validation branch May 1, 2026 14:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants